package com.gimhon.login.config;

import com.gimhon.login.interceptor.AuthInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;


@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Resource
    AuthInterceptor authInterceptor;


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        String[] exclude = new String[]{
                "/",
                "/img/**",
                "/js/**",
                "/css/**",
                "/config/**",
                "/user/register",
                "/user/login",
                "/page/login.html",
                "/page/register.html",
                "/error",
        };
        registry.addInterceptor(authInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(exclude);
    }
}
